﻿using System;
using System.Collections;
using UnityEngine;
public class UISystem : Singleton<UISystem>
{
    #region 生命周期管理
    private void OnEnable()
    {
        // 注册游戏动作处理器
        ActionSystem.AttachPerformer<WaveGA>(WavePerformer);   // 敌人回合
       // ActionSystem.SubScribeReaction<EnemyTurnGA>(EnemyTurnPostReaction, ReactionTiming.PRE);
    }



    private void OnDisable()
    {
        // 注销游戏动作处理器
        ActionSystem.DetachPerformer<WaveGA>();
        //ActionSystem.UnsubScribeReaction<EnemyTurnGA>(EnemyTurnPostReaction, ReactionTiming.PRE);
    }
    #endregion

    private IEnumerator WavePerformer(WaveGA gA)
    {
        string waveName = gA.WaveName;
        FindObjectOfType<WaveUI>().SetWave(waveName);
        yield return new WaitForSeconds(2f); // 等待

    }
    private void EnemyTurnPostReaction(EnemyTurnGA gA)
    {
        ActionSystem.instance.AddReaction(new WaveGA("敌人回合"));

    }
}
